#include <vector>
using namespace std;
class Solution
{
public:
    int minCostClimbingStairs(vector<int> &cost)
    {
        vector<int> add(cost.size() + 1, 0);
        cost.push_back(0);
        //1. 某一个点只能由前一个或者前二个节点到达
        //2. 动态一直选择最小的由来节点
        int pev_1 = cost[1], pev_2 = cost[0];
        for (int i = 2; i < add.size(); i++)
        {
            add[i] = cost[i] + min(pev_1, pev_2);
            pev_2=pev_1;
            pev_1=add[i];
        }
        return add.back();
    }
};